'use strict';

/* 设置 */

var React = require('react-native');

var {
	StyleSheet,
	View,
	Text,
	Image,
	ScrollView,
	TouchableOpacity,
	ToastAndroid,
} = React;

var {
	Log,
	AppLauncher
} = require('react-native-yankai-utils');

var MTDView = require('./MTDView');

module.exports = React.createClass({

	render: function() {
		return (
			<ScrollView contentContainerStyle={styles.container}>
				<TouchableOpacity style={styles.item} onPress={this.launchWeChat}>
					<Text style={styles.title}>打开微信</Text>
				</TouchableOpacity>
				<TouchableOpacity style={styles.item} onPress={this.launchWeibo}>
					<Text style={styles.title}>打开XX</Text>
				</TouchableOpacity>
				<MTDView style={{backgroundColor:'red'}}>
					<Text>MTDView1</Text>
					<Text>MTDView1</Text>
					<Text>MTDView1</Text>
					<Text>MTDView1</Text>
					<Text>MTDView1</Text>
				</MTDView>
			</ScrollView>
		)
	},

	launchWeChat: function() {

		function callback(args) {
			if (args.code == AppLauncher.LAUNCH_CALLBACK_CODE_NOT_FOUND) {
				ToastAndroid.show('没有安装微信', ToastAndroid.SHORT);
			}
			Log.info(args);
		}

		AppLauncher.launch('com.tencent.mm', callback);
	},

	launchWeibo: function() {

		function callback(args) {
			if (args.code == AppLauncher.LAUNCH_CALLBACK_CODE_NOT_FOUND) {
				ToastAndroid.show('没有安装XX', ToastAndroid.SHORT);
			}
			Log.info(args);
		}

		AppLauncher.launch('xyz.yankai.xx', callback);
	}
});

var styles = StyleSheet.create({

	container: {
		flex: 1,
		backgroundColor: '#EEE'
	},

	item: {
		backgroundColor: '#FFF',
		padding: 15,
		borderColor: '#CCC',
		borderBottomWidth: 1,
		flexDirection: 'row',
	},
	title: {
		color: '#000',
		fontSize: 20,
	}
});